package heip.generator.generer;

import heip.generator.entity.EntityClazz;
import heip.generator.entity.TableClazz;

import java.util.HashMap;
import java.util.Map;

import cn.org.rapid_framework.generator.provider.java.model.JavaClass;




/**
 * 生成service类
 * @author HSWHM
 *
 */
public class ServiceGenerator2 extends AbstractGenerator{
	/**
	 *需要手动修改的变量 
	 */
	//模块名
	private String moduleName;
	
	public  ServiceGenerator2(String moduleName){
		this.moduleName = moduleName;
		gg.put("moduleName",this.moduleName);
	}
	
	
	
	public void generatorSingleBS(TableClazz entityTable) throws Exception{
		generGrid(entityTable);
	}
	public void generGrid(TableClazz tableClass) throws Exception{
		Map<String,Object> map = new HashMap<String,Object>();
		map.put("tableClazz", tableClass);
		generator.generateByMap(map, gridMainTem);
		for(TableClazz subClass: tableClass.getSubClazzes()){
			generatorSubGrid(subClass,tableClass);
		}
	}
	public void generatorSubGrid(TableClazz subClass,TableClazz fatherClazz) throws Exception{
		Map map = new HashMap();		
		map.put("clazz",subClass);
		map.put("mainClazzId",subClass.getFkProperty().getName());
		map.put("fatherClazz", fatherClazz);
		map.put("entityCnName", subClass.getTableAlias());
		generator.generateByMap(map,gridSubTem);
	}
	private static final String gridMainTem= "TEMPLATE_1.0/SERVICE_TEMPLATE/twoTable/grid/main";
	private static final String sigleTem = gridMainTem;
	private static final String gridSubTem= "TEMPLATE_1.0/SERVICE_TEMPLATE/twoTable/grid/sub";
	private static final String cacheMainTem= "TEMPLATE_1.0/SERVICE_TEMPLATE/twoTable/temTable/main";
	private static final String cacheSubTem= "TEMPLATE_1.0/SERVICE_TEMPLATE/twoTable/temTable/sub";
	private static final String threeMain= cacheMainTem;
	private static final String threeSubMain= "TEMPLATE_1.0/SERVICE_TEMPLATE/threeTable/submain";
	private static final String threeSub= "TEMPLATE_1.0/SERVICE_TEMPLATE/threeTable/sub";
}